import { h } from 'vue';
import {FormSchema} from "@/components/Form";
export const columns = [
    // {
    //     type: 'selection',
    //     key: 'selection'
    // },
    {
      title: '用户ID',
      key: 'userId',
      width: 40,
    },
    {
      title: '角色ID',
      key: 'roleId',
      width: 80,
    },
    {
      title: '游戏名字',
      key: 'gameName',
      width: 80,
    },
    {
        title: '角色等级',
        key: 'roleLv',
        width: 60,
    },
    {
      title: '是否收录',
      key: 'isRecord',
      width: 50,
      render(row) {
          return h(
          'span',
           { style: row.isRecord === true ? 'color:red' : 'green' },
            {
              default: () => (row.isRecord === true ? '是' : '否'),
            }
          );
      },
   },
    {
        title: '充值金额(当前角色)',
        key: 'roleRechargeAmount',
        render(row) {
            return h(
            'span',
             { style: 'color:red'},
              {
                default: () => (row.roleRechargeAmount ===  '' ? '0' : row.roleRechargeAmount),
              }
            );
        },
        width: 80,
    },
    {
        title: '总充值金额',
        key: 'totalRechargeAmount',
        render(row) {
            return h(
                'span',
                { style: 'color:red'},
              {
                default: () => (row.totalRechargeAmount ===  '' ? '0' : row.totalRechargeAmount),
              }
            );
        },
        width: 60,
    },
    {
        title: '是否丢失',
        key: 'isLose',
        width: 50,
        render(row) {
            return h(
            'span',
             { style: row.isLose === true ? 'color:red' : 'green' },
              {
                default: () => (row.isLose === true ? '是' : '否'),
              }
            );
        },
    },
    {
        title: '召回次数',
        key: 'recallNums',
        width: 50,
    },
    {
        title: '召回金额',
        key: 'recallAmount',
        width: 50,
        render(row) {
            return h(
            'span',
            { style: row.recallAmount === '' ? 'color:red' : 'green' },
              {
                default: () => (row.recallAmount ===  '' ? '0' : row.recallAmount),
              }
            );
        },
    },
    {
        title: '维护次数',
        key: 'opNums',
        width: 50,
    },
    {
        title: '维护类型',
        key: 'recordType',
        width: 100,
        render(row) {
            return h(
            'span',
             { style: 'color:red'},
              {
                default: () => (row.recordType ===  'BasicMaintenance' ? '基础维护' : row.recordType ===  'UserSurvey' ? '用户问卷调查' : row.recordType ===  'GameContentPush' ? '游戏内容推送' : row.recordType ===  'GiftPackSending' ? '礼包发送' : ''),
              }
            );
        },
    },
    {
        title: '最后登录日期',
        key: 'lastLoginAt',
        width: 90,
    },
    {
        title: '备注',
        key: 'desc',
        width: 100,
    },
    {
        title: '创建日期',
        key: 'createdAt',
        width: 90,
    },
    {
        title: '编辑日期',
        key: 'updatedAt',
        width: 90,
    },
];

export const editCloumns: FormSchema[] = [
    {
        field: 'isRecord',
        label: '是否收录：',
        component: 'NSwitch',
        defaultValue: false,
    },
    {
        field: 'recordType',
        label: '维护类型：',
        rules: [{ required: true, message: '请选择维护类型', trigger: ['blur'] }],
        slot: 'recordTypeMap',
    },
    {
        field: 'desc',
        component: 'NInput',
        label: '维护备注：',
        componentProps: {
          placeholder: '维护备注（可选）',
        },
    },
];

export const schemas: FormSchema[] =[
    {
      field: 'roleId',
      component: 'NInput',
      label: '角色ID:',
      componentProps: {
        placeholder: '请输入完整角色ID',
        onInput: (e: any) => {
          console.log(e);
        },
      },
    },
    {
      field: 'userId',
      component: 'NInput',
      label: '用户ID:',
      componentProps: {
        placeholder: '请输入用户ID',
        onInput: (e: any) => {
          console.log(e);
        },
      },
    },
    {
      field: 'loseStatus',
      component: 'NSelect',
      label: '丢失状态:',
      defaultValue: '1',
      componentProps: {
        options: (function () {
          var arr = [
            {
              label: '已丢失',
              value: '1',
            },
            {
              label: '未丢失',
              value: '0',
            },
          ];
          return arr;
        })(),
        onInput: (e: any) => {
          console.log(e);
        },
      },
    },
    {
      field: 'recordStatus',
      component: 'NSelect',
      label: '收录状态:',
      defaultValue: '1',
      componentProps: {
        options: (function () {
          var arr = [
            {
              label: '已收录',
              value: '1',
            },
            {
              label: '未收录',
              value: '0',
            },
          ];
          return arr;
        })(),
        onInput: (e: any) => {
          console.log(e);
        },
      },
    },
    // {
    //   field: 'gameName',
    //   label: '游戏名字:',
    //   slot: 'gameSelect',
    // },
];